
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="ntModalLabel" type="{$type}">{$title}</h4>
</div>
<div class="modal-body">
        <div class="row clearfix">
                <div class="col-md-12 column">
                    <div class="alert alert-dismissable alert-info">
                        <button type="button" class="close">×</button>
                         <p></p>
                    </div>
                </div>
            </div>
	<table class="table table-striped table-hover ntTable" style="padding-top:0">
        <tbody>
           	<tr>
            	<td>{:lang('name')}<span class="required"></span></td>
                <td>
                	<input type="text" class="form-control" id="name" placeholder="{:lang("language_name")}" value="{if isset($language)}{$language.name}{/if}">
                </td>
            </tr>
           	<tr>
            	<td>{:lang('code')}</td>
                <td>
                	<input type="text" class="form-control" id="code" placeholder="{:lang("language_code")}" value="{if isset($language)}{$language.code}{/if}">
                </td>
            </tr>
                    <input type="hidden" class="form-control" id="old_icon"  value="{if isset($language)}{$language.icon}{/if}">
           	<tr>
            	<td>{:lang("icon_path")}</td>
                <td style="text-align: right;">
                    <input type="file" name="" id="file" style="opacity: 0;float: left;">
                	<button type="button" class="btn btn-primary up_img">{:lang("click_the_icon_and_upload")}</button>
                </td>
            </tr>
           	<tr>
            	<td>{:lang('classify')}</td>
                <td>
                	<input type="text" class="form-control" id="drank" placeholder="{:lang('classify')}" value="{if isset($language)}{$language.drank}{/if}">
                </td>
            </tr>
        	<tr>
            	<td>{:lang('status')}</td>
                <td>
                    <label class="checkbox-inline">
                        {if isset($language)}
                        {if condition="$language.status==3"}
                        <input type="checkbox" name="optionsCheckboxsinline" id="hide" value="hide" checked> {:lang("hide")}
                        {else /}
                        <input type="checkbox" name="optionsCheckboxsinline" id="hide" value="hide" > {:lang("hide")}
                        {/if}
                        {else /}
                        <input type="checkbox" name="optionsCheckboxsinline" id="hide" value="hide" > {:lang("hide")}
                        {/if}
                        
                    </label>
                </td>
            </tr>
            <input type="hidden" id="id" value="{if isset($id)}{$id}{/if}">
        </tbody>
    </table>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>{:lang('cancel')}</button>
    <button type="button" class="btn btn-primary save" style="padding-left:24px;padding-right:24px"><span class="glyphicon glyphicon-floppy-disk"></span>{:lang('save')}</button>
</div>
<script type="text/javascript">
    $('.save').click(function(){
        if($('#ntModalLabel').attr('type') == 'add'){
            var url ='/admin/language/addopen?request=insert';
        }else{
            var url ='/admin/language/editopen?request=update';
        }
        var formData = new FormData();
        var file=$('#file').prop('files')
        if($('#file').val()){
            file[0].path=$('#file').val()
            formData.append('file',file[0]);
        }
        
        formData.append('name',$('#name').val());
        formData.append('code',$('#code').val());
        formData.append('icon',$('#icon').val());
        formData.append('old_icon',$('#old_icon').val());
        formData.append('drank',$('#drank').val());
        formData.append('status',$('#hide').prop('checked'));
        formData.append('id',$('#id').val());
        $.ajax({
            url:url,
            type:'POST',
            data:formData,
            cache: false,
            contentType: false,    //不可缺
            processData: false,    //不可缺
            success:function(data){
                data = JSON.parse(data)
                if(data.status==1){
                    change_mes_type('.alert',data.status)
                    $('.alert').show()
                    $('.alert p').html('*'+data.msg+'<br>')
                    $('#language_editModal').modal('hide')
                }else{
                    change_mes_type('.modal-body .alert',data.status)
                    $('.modal-body .alert').show()
                    $('.modal-body .alert p').html('*'+data.msg+'<br>')
                }
            }
        });
    });
    $('.up_img').click(function(){
        $('#file').click()
    })
</script>
